﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Weapp.Client;

namespace Weapp
{
    public partial class Registro : Form
    {
        private readonly IWeappWebServiceClient _client;
        public Registro()
        {
            InitializeComponent();
            _client = new WeappWebServiceClient();  
        }

        private void textField1_Load(object sender, EventArgs e)
        {

        }

        private void btnReg_Click(object sender, EventArgs e)
        {
            string aviso;
            if (txtAcc.FieldValue == String.Empty || txtNombre.FieldValue == string.Empty || txtPass.FieldValue == string.Empty || txtPassV.FieldValue == string.Empty)
            {
                aviso = "Falta: ";
                if (txtAcc.FieldValue == String.Empty)
                {
                    aviso = aviso + "-Acount-";
                }
                if (txtNombre.FieldValue == string.Empty)
                {
                    aviso = aviso + "-Nombre-";
                }
                if (txtPass.FieldValue == string.Empty)
                {
                    aviso = aviso + "-Clave-";
                }
                if (txtPassV.FieldValue == string.Empty)
                {
                    aviso = aviso + "-Verificacion-";
                }
            }
            else
            {
                if (txtPass.FieldValue == txtPassV.FieldValue)
                {
                    if(_client.NewUserDnd(txtAcc.FieldValue, txtPass.FieldValue, txtNombre.FieldValue,
                        comboRole.Text))
                    {
                         aviso = "registro satisfactorio";
                    }
                    else
                    {
                        aviso = "usuario ya registrado";
                    }
                   
                }
                else
                {
                    aviso = "Los passwords no coinciden";
                }
            }
            MessageBox.Show(aviso);
            

            
        }
    }
}
